#!/usr/bin/env python3
"""
获取 Edge-TTS 所有可用语音列表

使用方法：
python list_voices.py
"""

import asyncio
import edge_tts

async def main():
    print("=" * 80)
    print("正在获取 Edge-TTS 所有可用语音...")
    print("=" * 80)
    
    voices = await edge_tts.list_voices()
    
    # 过滤中文相关语音
    chinese_voices = [
        v for v in voices 
        if v['Locale'].startswith(('zh-CN', 'zh-HK', 'zh-TW'))
    ]
    
    print(f"\n找到 {len(chinese_voices)} 个中文语音：\n")
    
    # 按地区分组
    regions = {
        'zh-CN': '🇨🇳 普通话',
        'zh-HK': '🇭🇰 粤语',
        'zh-TW': '🇹🇼 台湾话'
    }
    
    for locale, region_name in regions.items():
        region_voices = [v for v in chinese_voices if v['Locale'].startswith(locale)]
        if region_voices:
            print(f"\n{region_name} ({len(region_voices)} 个)")
            print("-" * 80)
            for voice in region_voices:
                gender = "👨 男声" if voice['Gender'] == 'Male' else "👩 女声"
                name = voice['ShortName']
                friendly_name = voice['FriendlyName']
                print(f"  {gender} | {name}")
                print(f"         {friendly_name}")
                print()
    
    # 输出所有语音名称（方便复制）
    print("\n" + "=" * 80)
    print("所有中文语音名称（复制使用）：")
    print("=" * 80)
    for voice in chinese_voices:
        gender = "女声" if voice['Gender'] == 'Female' else "男声"
        locale_name = voice['Locale']
        print(f"    '{voice['ShortName']}',  # {voice['LocalName']} ({gender}) - {locale_name}")
    
    print("\n" + "=" * 80)
    print(f"总计: {len(chinese_voices)} 个中文语音")
    print("=" * 80)

if __name__ == '__main__':
    asyncio.run(main())

